# coding: utf-8

import re
from collections import defaultdict



data = [
    {
        'name1': 'port',
        'type1': 'input',
        'default1': '10086',
        'desc1': u'默认端口',
        'required1': 'required'
    },
    {
        'name1': 'listen_ip',
        'type1': 'input',
        'default1': '0.0.0.0',
        'desc1': u'默认监听嗲子',
    }
]

data_list = {'name1': 'port', 'type1': 'input', 'default1': '10086', 'required1': 'required', 'desc1': u'默认端口', 'name2': 'listend_ip', 'type2': 'input', 'default2': '0.0.0.0', 'desc2': u'默认监听地址'}




a = VarDict({'required': False})
a['required'] = 'required'
a['name'] = 'name'
print a

p = re.compile('\d')
vars_dict = defaultdict(VarDict)
for k, v in data_list.items():
    field, index = search_filed(k)
    if not field or not index:
        continue
    vars_dict[index][field] = v

print vars_dict



def name_patter(name):
    pattern = re.compile('name')



